package top.leetcode;

import java.util.Objects;

/**
 * @Desc
 * @Author houruiyang
 * @Date 2022/12/23
 **/
public class _058 {

    public int lengthOfLastWord(String s) {

        int index = s.length() -1;

        while (s.charAt(index) == ' ') {
            index--;
        }

        int wordLength = 0;
        while (index >=0 && s.charAt(index) != ' ') {
            index--;
            wordLength++;
        }

        return wordLength;
    }
}
